using System.Collections.Generic;
using System.IO;
using JsonRpcGen.TypeHandler;

namespace JsonRpcGen.ParameterHandler
{
    internal class ParamHandler
    {
        public string OriginalName { get; set; }
        public string Name { get; set; }
        public string Type { get; set; }

        public ParamHandler(string name, string type)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }
            OriginalName =Name= name;
            if (Global.IsReservedName(Name))
            {
                Name = Name + "_arg";
            }
            Type = type;
        }

        public virtual void WriteType(StreamWriter writer, Dictionary<string, string> replacements)
        {
            
        }

        public virtual string GetDefault()
        {
            switch (Type)
            {
                case "int":
                    return "0";
                case "bool":
                    return "false";
                case "double":
                    return "0";
            }
            if (EnumTypeHandler.EnumTypes.Contains(Type))
            {
                return "0";
            }
            return "null";
        }
    }
}